package androidx.appcompat.widget;

import android.content.Context;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.view.View;
import android.widget.PopupWindow;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import o.ah.g;
import o.cw;
import o.iw;

class AppCompatPopupWindow extends PopupWindow {
    private static final boolean ॱ = (VERSION.SDK_INT < 21);
    private boolean ˊ;

    public AppCompatPopupWindow(@NonNull Context context, @Nullable AttributeSet attributeSet, @AttrRes int i) {
        super(context, attributeSet, i);
        ˋ(context, attributeSet, i, 0);
    }

    public AppCompatPopupWindow(@NonNull Context context, @Nullable AttributeSet attributeSet, @AttrRes int i, @StyleRes int i2) {
        super(context, attributeSet, i, i2);
        ˋ(context, attributeSet, i, i2);
    }

    private void ˋ(Context context, AttributeSet attributeSet, int i, int i2) {
        cw ॱ = cw.ॱ(context, attributeSet, g.ˊˑ, i, i2);
        if (ॱ.ᐝ(g.ˊꜟ)) {
            ˎ(ॱ.ˋ(g.ˊꜟ, false));
        }
        setBackgroundDrawable(ॱ.ˋ(g.ˊᐨ));
        ॱ.ॱ();
    }

    public void showAsDropDown(View view, int i, int i2) {
        if (ॱ && this.ˊ) {
            i2 -= view.getHeight();
        }
        super.showAsDropDown(view, i, i2);
    }

    public void showAsDropDown(View view, int i, int i2, int i3) {
        if (ॱ && this.ˊ) {
            i2 -= view.getHeight();
        }
        super.showAsDropDown(view, i, i2, i3);
    }

    public void update(View view, int i, int i2, int i3, int i4) {
        int height;
        if (ॱ && this.ˊ) {
            height = i2 - view.getHeight();
        } else {
            height = i2;
        }
        super.update(view, i, height, i3, i4);
    }

    private void ˎ(boolean z) {
        if (ॱ) {
            this.ˊ = z;
        } else {
            iw.ˎ((PopupWindow) this, z);
        }
    }
}
